﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class EscapeForAndroid : MonoBehaviour {

    public List<Button> li = new List<Button>();

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("a ..... ");
            foreach( var item in li )
            {
                if ( item.IsActive () )
                {
                    Debug.Log(item);
                    RectTransform rt = item.gameObject.GetComponent<RectTransform>();
                    if (rt.position.z >= 100)
                        continue;

                    item.onClick.Invoke();

//                    item.onClick.Invoke();
                    return;
                }
            }

           
            

        }
    }
}
